#!/bin/bash


let testNum=10
let l=400
let r=1000
let k=8
let lamda=1
#清空存数据的文件
filePath="resultData/wt.txt"
cat /dev/null > $filePath
> $filePath

echo "OPT"
for wt in 100 500 1000 1500
do
    let n=0
    let t=0
    let m=0
    for ((i=0;i<$testNum;i++))
    do
        temp=`../../../build/OPT $l $r ../${wt}_${wt}_data.txt`
        temp=($temp)
        n=`echo $n ${temp[1]}|awk '{printf("%.6f",$1+$2)}'`
        t=`echo $t ${temp[2]}|awk '{printf("%.6f",$1+$2)}'`
        m=`echo $m ${temp[3]}|awk '{printf("%.6f",$1+$2)}'`
    done
    echo $n $t $m $testNum|awk '{printf("OPT %.6f %.6f %.6f \n",$1/$4,$2/$4,$3/$4)}' >> $filePath
    # ../../../build/OPT $l $r ../${n}_${n}_data.txt >> $filePath
done

echo "Baseline"
for wt in 100 500 1000 1500
do
    let n=0
    let t=0
    let m=0
    for ((i=0;i<$testNum;i++))
    do
        temp=`../../../build/Baseline $l $r ../${wt}_${wt}_data.txt`
        temp=($temp)
        n=`echo $n ${temp[1]}|awk '{printf("%.6f",$1+$2)}'`
        t=`echo $t ${temp[2]}|awk '{printf("%.6f",$1+$2)}'`
        m=`echo $m ${temp[3]}|awk '{printf("%.6f",$1+$2)}'`
    done
    echo $n $t $m $testNum|awk '{printf("Baseline %.6f %.6f %.6f \n",$1/$4,$2/$4,$3/$4)}' >> $filePath
    # ../../../build/Baseline $l $r ../${wt}_${wt}_data.txt >> $filePath
done

echo "Baseline2"
for wt in 100 500 1000 1500
do
    let n=0
    let t=0
    let m=0
    for ((i=0;i<$testNum;i++))
    do
        temp=`../../../build/Baseline2 $l $r ../${wt}_${wt}_data.txt`
        temp=($temp)
        n=`echo $n ${temp[1]}|awk '{printf("%.6f",$1+$2)}'`
        t=`echo $t ${temp[2]}|awk '{printf("%.6f",$1+$2)}'`
        m=`echo $m ${temp[3]}|awk '{printf("%.6f",$1+$2)}'`
    done
    echo $n $t $m $testNum|awk '{printf("Baseline2 %.6f %.6f %.6f \n",$1/$4,$2/$4,$3/$4)}' >> $filePath
    # ../../../build/Baseline $l $r ../${wt}_${wt}_data.txt >> $filePath
done

echo "KS"
for wt in 100 500 1000 1500
do
    let n=0
    let t=0
    let m=0
    for ((i=0;i<$testNum;i++))
    do
        temp=`../../../build/KS $l $r $k $lamda ../${wt}_${wt}_data.txt`
        temp=($temp)
        n=`echo $n ${temp[1]}|awk '{printf("%.6f",$1+$2)}'`
        t=`echo $t ${temp[2]}|awk '{printf("%.6f",$1+$2)}'`
        m=`echo $m ${temp[3]}|awk '{printf("%.6f",$1+$2)}'`
    done
    echo $n $t $m $testNum|awk '{printf("KS %.6f %.6f %.6f \n",$1/$4,$2/$4,$3/$4)}' >> $filePath
    # ../../../build/KS $l $r $k $lamda ../${n}_${n}_data.txt >> $filePath
done

echo "Kmeans"
for wt in 100 500 1000 1500
do
    let n=0
    let t=0
    let m=0
    for ((i=0;i<$testNum;i++))
    do
        temp=`../../../build/Kmeans $l $r $k $lamda ../${wt}_${wt}_data.txt`
        temp=($temp)
        n=`echo $n ${temp[1]}|awk '{printf("%.6f",$1+$2)}'`
        t=`echo $t ${temp[2]}|awk '{printf("%.6f",$1+$2)}'`
        m=`echo $m ${temp[3]}|awk '{printf("%.6f",$1+$2)}'`
    done
    echo $n $t $m $testNum|awk '{printf("GS %.6f %.6f %.6f \n",$1/$4,$2/$4,$3/$4)}' >> $filePath
    # ../../../build/Kmeans $l $r $k $lamda ../${n}_${n}_data.txt >> $filePath
done